package cn.spring.security.learn;

import de.codecentric.boot.admin.server.config.EnableAdminServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.Map;
import java.util.stream.Stream;

@Slf4j
@EnableAdminServer
@SpringBootApplication
public class SecurityApplication implements CommandLineRunner {

    @Autowired
    private ApplicationContext applicationContext;

    public static void main(String[] args) {
        SpringApplication.run(SecurityApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        Stream.of(beanDefinitionNames).forEach(beanName -> {
            log.info("beanName:{}", beanName);
            // Object bean = applicationContext.getBean(beanName);
            // System.out.println("Spring bean : " + bean);
        });

       /* Map<String, LoginController> map = applicationContext.getBeansOfType(LoginController.class);
        map.forEach((beanName, bean) -> {
            System.out.println("beanName ： " + beanName);
            System.out.println("bean ： " + bean);
        });*/
    }
}
